/*
 * CS 567 GUI - Semester Project - "DecisionLists"
 * Jason Frank
 * Spring 2011
 *
 * This File:
 *
 */

package Decision_Lists;

import java.awt.Dimension;
import java.awt.Font;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.filechooser.FileNameExtensionFilter;

/*
 */
public class AddItemView extends JPanel implements DL_ViewInterface {

  ///////////////////////////
  //// CLASS VARS ///////////
  String viewName = "AddItem";
  DL_Model model;

  // WIDGETS
          //JButton saveItemBtn = new JButton("Save Item");
          //JButton cancelBtn = new JButton("Cancel & Return to View");
  JLabel addItemLabel = new JLabel("Add List Item");
  JLabel nameLabel    = new JLabel("Name: ");
  JTextField nameField = new JTextField();
  JLabel mainPicLabel = new JLabel("Main Pic: ");
  JFileChooser mainPicChooser = new JFileChooser();

/*
  FileNameExtensionFilter picFilenameFilter = new FileNameExtensionFilter("JPG & GIF Images", "jpg", "gif");
  mainPicChooser.setFileFilter(picFilenameFilter);
  int returnVal = mainPicChooser.showOpenDialog(parent);
  if(returnVal == JFileChooser.APPROVE_OPTION) {
     System.out.println("You chose to open this file: " +
          mainPicChooser.getSelectedFile().getName());
  }
*/

  protected Font addListItemLabelFont = new    Font("Helvetica", Font.BOLD,  19);

  //// end Class Vars ////////
  ////////////////////////////

  // Constructor
  public AddItemView(DL_Model model)  {

    this.model = model;

    initVisibleElements();
    layoutPanel();

  } ////// end constructor //////


  protected void initVisibleElements() {

    addItemLabel.setFont(addListItemLabelFont);
  }

  
  protected void layoutPanel()  {

    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

      //    Box topBtnsBox = Box.createHorizontalBox();
      //    topBtnsBox.add(saveItemBtn);
      //    topBtnsBox.add(cancelBtn);
      //    add(topBtnsBox);

    add(Box.createRigidArea(new Dimension(20, 0))); // Padding on left side of everything

    Box mainVertBox = Box.createVerticalBox();
    mainVertBox.add(Box.createRigidArea(new Dimension(0, 20))); // Top padding
    mainVertBox.add(addItemLabel);
    mainVertBox.add(Box.createRigidArea(new Dimension(0, 15))); // padding

    Box nameHorizBox = Box.createHorizontalBox();
    nameHorizBox.add(nameLabel);
    nameHorizBox.add(nameField);
    mainVertBox.add(nameHorizBox);

    Box mainPicHorizBox = Box.createHorizontalBox();
    mainPicHorizBox.add(mainPicLabel);
    mainPicHorizBox.add(mainPicChooser);
    mainVertBox.add(mainPicHorizBox);


    // Finally, add the main box to this panel
    add(mainVertBox);
    add(Box.createHorizontalGlue()); // make the main box left aligned

  } //////////// end layoutPanel() ////////////


  //////////////////////////////////////////////////////
  /// METHODS REQUIRED BY THE INTERFACE ////////////////
  public void curViewChanged(String old_view_name, String new_view_name) {
  }
  // Model calls this to inform views of an added (new) list item.
  //  The views will then probably need to re-layout their list items to reflect the change.
  public void itemAdded(List_Item_Data newItem) {
    // Do nothing
  }
  // Model calls this to inform views of a changed list item (i.e., new item added, old item deleted, etc).
  //  The views will then probably need to re-layout their list items to reflect the change.
  public void itemChanged() {
    // Do nothing
  }

  public String getViewName() {
    return viewName;
  }
  //////// end methods required by the interface ///////////
  //////////////////////////////////////////////////////////

  

} //////////////////// end class AddItemView /////////////////////////////
